package com.leoman.spinningmachine.tab2;

import android.content.Context;
import android.util.Log;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.leoman.helper.adapter.BaseRecyclerAdapter;
import com.leoman.helper.util.FrescoUtil;
import com.leoman.helper.util.LogUtil;
import com.leoman.spinningmachine.R;
import com.leoman.spinningmachine.bean.MyMessageBean;
import com.leoman.spinningmachine.constant.Constant;
import com.leoman.spinningmachine.util.DateUtil;
import com.leoman.spinningmachine.util.SharedPreferencesUtils;

import java.util.List;

/**
 * Created by Administrator on 2018/4/25.
 * 消息中心适配器
 */

public class MsgAdapter extends BaseRecyclerAdapter<MyMessageBean> {

    Context mContext;

    public MsgAdapter(Context mContext, int layoutResId, List<MyMessageBean> data) {
        super(layoutResId, data);
        this.mContext = mContext;
    }

    @Override
    protected void bindTheData(BaseViewHolder holder, MyMessageBean bean, int position) {
        SimpleDraweeView iv_pic = holder.findViewById(R.id.iv_pic);
        TextView tv_title = holder.findViewById(R.id.tv_title);
        TextView tv_content = holder.findViewById(R.id.tv_content);
        TextView tv_time = holder.findViewById(R.id.tv_time);
//        tv_title.setText(data.title);
//        tv_content.setText(data.content);

        FrescoUtil.setImg(mContext, iv_pic, bean.getHeadImage());
        String tit = "";
        if (1 == bean.getType()) {
            tit = "打卡通知:";
            tv_title.setText("打卡通知:" + bean.getNickname());
        } else if (2 == bean.getType()) {
            tit = "审批人:";
            tv_title.setText("审批人:" + SharedPreferencesUtils.getInstance().getString(Constant.USER_REALNAME));
        } else if (3 == bean.getType()) {
            tit = "";
            tv_title.setText("" + bean.getNickname());
        } else if (4 == bean.getType()) {
            tit = "请假人:";
            tv_title.setText("请假人:" + bean.getNickname());
        }
//        tv_title.setText(tit + bean.getNickname());
        tv_content.setText("[" + bean.getTypeName() + "]" + bean.getReason());
        tv_time.setText("" + DateUtil.getyMdHms(bean.getCreateDate(), "MM月dd日"));
    }
}
